# Maintainer: Alberto Fanjul Alonso <albfan@gnome.org>

_realname=granite
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=6.2.0
pkgrel=3
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
pkgdesc="git repository viewer for GTK+/GNOME (mingw-w64)"
depends=( "${MINGW_PACKAGE_PREFIX}-libgee"
          "${MINGW_PACKAGE_PREFIX}-gtk3")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-itstool"
             "${MINGW_PACKAGE_PREFIX}-cc")
license=('spdx:LGPL-3.0-or-later')
url="https://github.com/elementary/granite"
source=("${_realname}-${pkgver}.tar.gz::https://github.com/elementary/${_realname}/archive/refs/tags/${pkgver}.tar.gz")
sha256sums=('067d31445da9808a802fca523630c3e4b84d2d7c78ae547ced017cb7f3b9c6b5')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  # clang error from vala generated file
  export CFLAGS="${CFLAGS} -Wno-incompatible-function-pointer-types"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson.exe setup \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    -Dwerror=false \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/meson.exe compile
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/meson.exe install --destdir "${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
